package com.bbcare.comm;

import java.util.Map;
import java.util.concurrent.ConcurrentHashMap;

import org.springframework.util.StringUtils;

/**
 * @name: 缓存数据存储类
 * @author: DemonLee
 * @createTime: 2017.5.9
 * @description: 内存存储，部分静态数据先查内存，再查redis
 * @modify:
 * 
 */
public class ConfCacheUtil {
    // private static final Log logger = LogFactory.getLog(ConfCacheUtil.class);

    public static Map<String, Object> queueInfoMap;// 队列缓存
    public static Map<String, Object> schemeInfoMap;// 方案缓存
    public static Map<String, Object> lostReasonMap;// 失访原因缓存

    private static ConfCacheUtil instance = new ConfCacheUtil();

    public static ConfCacheUtil getInstance() {
        return instance;
    }

    public ConfCacheUtil() {
        queueInfoMap = new ConcurrentHashMap<String, Object>();
        schemeInfoMap = new ConcurrentHashMap<String, Object>();
        lostReasonMap = new ConcurrentHashMap<String, Object>();
    }

    // 根据队列id获取队列名称
    public Object getQueueName(String queueId) {
        if (StringUtils.isEmpty(queueId)) {
            return null;
        }
        return queueInfoMap.get(queueId);
    }

    // 根据队列id设置队列名称
    public void setQueueName(String queueId, String queueName) {
        if (StringUtils.isEmpty(queueId)) {
            return;
        }
        queueInfoMap.put(queueId, queueName);
    }

    // 根据方案id获取方案名称
    public Object getSchemeName(String schemeId) {
        if (StringUtils.isEmpty(schemeId)) {
            return null;
        }
        return schemeInfoMap.get(schemeId);
    }

    // 根据方案id设置方案名称
    public void setSchemeName(String schemeId, String schemeName) {
        if (StringUtils.isEmpty(schemeId)) {
            return;
        }
        schemeInfoMap.put(schemeId, schemeName);
    }

    // 根据失访id获取失访名称
    public Object getReasonName(String reasonId) {
        if (StringUtils.isEmpty(reasonId)) {
            return null;
        }
        return lostReasonMap.get(reasonId);
    }

    // 根据失访id设置失访名称
    public void setReasonName(String reasonId, String reasonName) {
        if (StringUtils.isEmpty(reasonId)) {
            return;
        }
        lostReasonMap.put(reasonId, reasonName);
    }
}
